# 嵌套式，创建有规律的列表、字典、集合

# 创建列表
"""
# 创建 1~10的列表
lst = [i for i in range(1, 11)]
print(lst)

# 创建1~10偶数的列表
ove = [i for i in range(1, 11) if i % 2 == 0]
print(ove)

# 创建如下列表[(1,0),(1,1),(1,2),(2,0),(2,1),(2,2)]
lst1 = [(i, j) for i in range(1, 3) for j in range(3)]
print(lst1)
"""


# 字典推导式
"""
lst1 = ['name', 'age', 'sex']
lst2 = ['liu', 20, 'woman']
dic = {lst1[i]: lst2[i] for i in range(len(lst2))}
print(dic)

num = {i: i**2 for i in range(1,11)}
print(num)

dic1 = {'m': 20, 'l': 30, 'n': 50}
lst3 = [key for key, value in dic1.items() if value > 20]
print(lst3)
"""

# 集合推导式
"""
lst = [1, 1, 3, 4]
set1 = {i**2 for i in lst}
print(set1)
"""
